// src/App.tsx - 主应用组件
import { useSelector } from 'react-redux';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { App as AntApp } from 'antd';
import LoginPage from '@pages/login';
import AppLayout from '@pages/layout';
import { RootState } from '@/store';

// 主应用组件
const App = () => {
  const { isAuthenticated } = useSelector((state: RootState) => state.auth);

  return (
    <AntApp>
      <BrowserRouter>
        <Routes>
          <Route path="/login" element={<LoginPage />} />
          <Route path="/*" element={isAuthenticated ? <AppLayout /> : <Navigate to="/login" />} />
        </Routes>
      </BrowserRouter>
    </AntApp>
  );
};

export default App;